<template>
  <div>
    <common-card
      title="累计用户数"
      value="1,244,806">
      <template>
        <v-chart :options="getOptions()"/>
        <!-- <div id="total-user-chart" style="width: 100%; height: 100%"></div> -->
      </template>

      <template v-slot:footer>
        <div class="total-user-footer">
          <span>日同比 </span>
          <span class="emphasis">24.47%</span>
          <div class="increase"></div>
          <span style="margin-left: 10px">月同比 </span>
          <span class="emphasis">55.58%</span>
          <div class="decrease"></div>
        </div>
      </template>
    </common-card>
  </div>
</template>

<script>
import CommonCardMixin from '../../mixins/commonCardMixin'

export default {
  mixins: [CommonCardMixin],
  methods: {
    getOptions() {
      return {
        xAxis: {
          show: false
        },
        yAxis: {
          type: 'category',
          show: false
        },
        series: [
          {
            type: 'bar',
            stack: '总量',
            data: [310],
            barWidth: 10, // 柱状图的宽度
            itemStyle: {
              color: ['#45C946'],
            }
          },
          {
            type: 'bar',
            stack: '总量',
            data: [600],
            itemStyle: {
              color: ['#eee'],
            }
          },
          {
            type: 'custom',
            data: [310],
            renderItem: function (params, api) {
              const value = api.value(0);
              const endPoint = api.coord([value, 0]);

              return {
                type: 'group',
                position: endPoint,
                children: [
                  {
                    type: 'path',
                    shape: {
                      d: 'M1024 255.996 511.971 767.909 0 255.996 1024 255.996z',
                      x: -5,
                      y: -20,
                      width: 10,
                      height: 10,
                      layout: 'cover'
                    },
                    style: {
                      fill: "#45C946"
                    }
                  },
                  {
                    type: 'path',
                    shape: {
                      d: 'M0 767.909l512.029-511.913L1024 767.909 0 767.909z',
                      x: -5,
                      y: 10,
                      width: 10,
                      height: 10,
                      layout: 'cover'
                    },
                    style: {
                      fill: "#45C946"
                    }
                  }
                ]

              }
            }
          }
        ],
        grid: {
          left: 0,
          right: 0,
          top: 0,
          bottom: 0
        }
      }
    }
  }
}
</script>

<style>
.total-user-footer {
  display: flex;
  align-items: center;
}
</style>
